<?php

use yii\db\Migration;

/**
 * Handles the creation of table `price`.
 */
class m180416_034200_create_price_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('price', [
            'id' => $this->primaryKey(),
            'name' => $this->string(11)->notNull()->comment('品种名称'),
            'market' => $this->string(20)->notNull()->comment('市场名称'),
            'price_kg' => $this->float(6)->notNull()->comment('每公斤价格'),
            'price_jin' => $this->float(6)->notNull()->comment('每斤价格'),
            'date' => $this->string(11)->notNull()->comment('报送日期'),
        ]);
        $this->createIndex('查询索引', 'price', ['date', 'market', 'name'],true);
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('price');
    }
}
